package display;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import universe.Block;
import universe.BlockHandler;
import universe.Board;

import junit.framework.TestCase;

public class BlockDisplayTest extends TestCase {

	@SuppressWarnings("serial")
	static class TestFrame extends JFrame{
		BlockDisplay BD;

		@Override
		public void paint(Graphics arg0) {
			super.paint(arg0);
			BD.paintComponent(arg0);
		}
	}

	protected void setUp() throws Exception {
		super.setUp();

	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public static void main(String args[]){

		BlockHandler BH = new BlockHandler(new Block(universe.Utils.getBlockA()), new Board(15, 30));
		BH.setX(1);
		BH.setY(1);

		// il faut une game
		Container CONT = new Container();
		BlockDisplay BD = new BlockDisplay(CONT, BH);
		BD.setBlockHandler(BH);

		
		JFrame frame = new JFrame();
		frame.getContentPane().add(BD);
		 

		frame.setLocationRelativeTo(null);
		int fWidth = Utils.sideWidth * universe.Utils.getBlockWidth() + 60;
		int fHeight = Utils.sideWidth * universe.Utils.getBlockHeight() + 60;
		frame.setPreferredSize(new Dimension(fWidth, fHeight));
		frame.pack();


		frame.setVisible(true);

		int showDuration = 200;
		try{
			Thread.sleep(showDuration);

			for(int i=0; i<20; ++i){

				BH.setB(Block.getRandomBlock());
				frame.repaint();
				Thread.sleep(showDuration);

			}

			Thread.sleep(2000);

		}
		catch(Exception e) {

		}


		System.exit(0);
	}

}
